<?php

use think\migration\Migrator;
use think\migration\db\Column;

class AirQualityAqiCityRank extends Migrator
{
    public function up()
    {
        $table = $this->table('air_quality_aqi_city_rank');
        $table
            //step0:时间
            ->addColumn('publish_time', 'datetime', ['comment' => '发布时间'])

            //step:相关ID
            ->addColumn('region_id', 'integer', ['limit' => 11, 'default' => '53', 'comment' => '城市ID默认长治53'])

            //step1:aqi污染情况
            ->addColumn('aqi', 'string', ['limit' => 50, 'default' => '', 'comment' => '长治市当天的aqi的值'])
            ->addColumn('aqi_level', 'string', ['limit' => 50, 'default' => '', 'comment' => '长治市当天的aqi污染情况'])

            //step1:全国排名
            ->addColumn('country_aqi_rank', 'string', ['limit' => 50, 'default' => '', 'comment' => '全国aqi排名'])
            ->addColumn('country_total', 'string', ['limit' => 50, 'default' => '318', 'comment' => '全国城市数据'])
            ->addColumn('country_percent', 'decimal', ['precision'=>10, 'scale' => 2, 'default' => '0.00', 'comment' => '全国排名百分比'])

            //step2:“2+26”排名
            ->addColumn('28city_aqi_rank', 'string', ['limit' => 50, 'default' => '', 'comment' => '“2+26”排名'])
            ->addColumn('28city_total', 'string', ['limit' => 50, 'default' => '28', 'comment' => '“2+26”总数量'])
            ->addColumn('28city_percent', 'decimal', ['precision'=>10, 'scale' => 2, 'default' => '0.00', 'comment' => '“2+26”百分比'])

            //step3:全省排名
            ->addColumn('province_aqi_rank', 'string', ['limit' => 50, 'default' => '', 'comment' => '全省排名'])
            ->addColumn('province_total', 'string', ['limit' => 50, 'default' => '11', 'comment' => '全省总数量,山西有11个市'])
            ->addColumn('province_percent', 'decimal', ['precision'=>10, 'scale' => 2, 'default' => '0.00', 'comment' => '全省百分比'])

            //step4:汾渭平原排名
            ->addColumn('fenwei_aqi_rank', 'string', ['limit' => 50, 'default' => '', 'comment' => '汾渭平原排名'])
            ->addColumn('fenwei_total', 'string', ['limit' => 50, 'default' => '13', 'comment' => '汾渭平原总数量，11城2区'])
            ->addColumn('fenwei_percent', 'decimal', ['precision'=>10, 'scale' => 2, 'default' => '0.00', 'comment' => '汾渭平原百分比'])

            //step5:创建时间
            ->addColumn('create_time', 'datetime', ['comment' => '创建时间'])

            //注释
            ->setComment('空气质量 - AQI - 城市排名（天）')

            //引擎
            ->setEngine('InnoDB')
            ->save();
    }

    public function down()
    {
        $this->table('air_quality_aqi_city_rank_day')->drop();
    }
}
